﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Imaginecup.gameState.recycling.Observable;
using System.Collections;
using Imaginecup.gameState.recycling.Object.UI;

namespace Imaginecup.gameState.recycling.Entity
{
    public class GroupButtons : IObservable
    {
        private Dictionary<String ,IMyObserver> m_ObserverDic;
        public IValueChanged GetObserver(String key)
        {
            return (IValueChanged)m_ObserverDic[key];
        }

        public GroupButtons()
        {
            m_ObserverDic = new Dictionary<String, IMyObserver>();
        }

        public void AddObserver(String key ,IMyObserver observer)
        {
            if (!m_ObserverDic.ContainsValue(observer))
                m_ObserverDic.Add(key, observer);
        }

        public void DeleteObserver(String key)
        {
            if (m_ObserverDic.ContainsKey(key))
                m_ObserverDic.Remove(key);
        }

        public void NotifyObservers(object obj)
        {
            foreach (IMyObserver observerItem in m_ObserverDic.Values)
            {
                observerItem.Update(this, obj);
            }
        }
    }
}
